<?php
session_start ();
// 判断用户是否已经登录
if (! isset ( $_SESSION ["userinfo"] ) and empty ( $_SESSION ["userinfo"] ["userid"] )) {
	header ( "location:../index.php" );
	session_unset ();
	session_destroy ();
	exit ();
}
?>
<!DOCTYPE html>
<html>
<head>
<link href="../PersonalPhoto/Images/web_title.ico" rel="icon"
	type="image/x-icon" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!-- Add jQuery library -->
<script type="text/javascript" src="../tools/lib/jquery-1.10.2.min.js"></script>
<!-- Add fancyBox main JS and CSS files -->
<script type="text/javascript"
	src="../tools/source/jquery.fancybox.pack.js?v=2.1.5"></script>
<link rel="stylesheet" type="text/css"
	href="../tools/source/jquery.fancybox.css?v=2.1.5" media="screen" />

<script type="text/javascript">
	$(document).ready(function() {
		$('.fancybox').fancybox();
	});
</script>

<link href="./Resource/Style/base.yy.css" rel="stylesheet"
	type="text/css" />
<?php
// session_start ();
$myid = $_SESSION ["userinfo"] ["userid"];
// $myid = "xufeng520";
$myname = $_SESSION ["userinfo"] ["username"];
// $myname = "许峰";
require_once '../tools/SqlHelper.class.php';
$user_id = "";
if (isset ( $_GET ['dazhaohu'] )) { // 打招呼
                                    // 获取浏览器发过来的页面数据
	$user_id = $_GET ['dazhaohu'];
	$user_name_d = $_GET ['user_name'] . "你好，很高兴认识你！！";
	// 创建一个SqlHelper对象
	$sql = "INSERT INTO `message_tb` (`user_receiver_id`, `user_send_id`, `ms_content`) VALUES ('$user_id', '$myid', '$user_name_d')";
	$sqlHelper = new SqlHelper ();
	$res = $sqlHelper->execute_dql ( $sql );
	if (! ! $res) {
		echo "<script>alert('向" . $_GET ['user_name'] . "打招呼成功')</script>";
	} else {
		echo "<script>alert('向" . $_GET ['user_name'] . "打招呼失败')</script>";
	}
	// 关闭连接
	mysql_free_result ( $res );
	$sqlHelper->close_connect ();
} else if (isset ( $_GET ['attention'] )) { // 关注
                                            // 获取浏览器发过来的页面数据
	$user_id = $_GET ['attention'];
	$sql = "INSERT INTO `attention_tb` (`at_my_id`, `at_user_id`) VALUES ('$myid', '$user_id')";
	$sqlHelper = new SqlHelper ();
	$res = $sqlHelper->execute_dql ( $sql );
	if (! ! $res) {
		echo "<script>alert('关注" . $_GET ['user_name'] . "成功')</script>";
	} else {
		echo "<script>alert('关注" . $_GET ['user_name'] . "失败')</script>";
	}
	// 关闭连接
	mysql_free_result ( $res );
	$sqlHelper->close_connect ();
} else if (isset ( $_GET ['error'] )) {
	$user_id = $_GET ['error'];
	echo "<script>alert('该功能未开放，敬请期待！！！')</script>";
} else if (isset ( $_GET ['user_id'] )) {
	$user_id = $_GET ['user_id'];
	// $user_id = "xiaoyan";
}
$sql = "select * from `user_tb` where `user_id`='$user_id'";
// 创建一个SqlHelper对象
$sqlHelper = new SqlHelper ();
$row = $sqlHelper->execute_dql ( $sql );
$res = mysql_fetch_array ( $row );
$user_name = $res ['user_name'];

$sql = "select * from `personal_data_tb` where `user_id`='$user_id'";
// 创建一个SqlHelper对象
$row = $sqlHelper->execute_dql ( $sql );
$res = mysql_fetch_array ( $row );
$user_sex = $res ['ps_sex'];
if ($user_sex == "0") {
	$user_sex = "男";
} else {
	$user_sex = "女";
}
$ps_qq = $res ['ps_qq'];
$ps_height = $res ['ps_height'];
$ps_blood_type = $res ['ps_blood_type'];
$ps_weight = $res ['ps_weight'];
$ps_profession = $res ['ps_profession'];
if ($ps_profession == "0") {
	$ps_profession = "未填写";
} else if ($ps_profession == "1") {
	$ps_profession = "在校学生";
} else if ($ps_profession == "2") {
	$ps_profession = "军人";
} else if ($ps_profession == "3") {
	$ps_profession = "私营业主";
} else if ($ps_profession == "4") {
	$ps_profession = "企业职工";
} else if ($ps_profession == "5") {
	$ps_profession = "农业劳动者";
} else if ($ps_profession == "6") {
	$ps_profession = "政府机关/事业单位工作者";
} else if ($ps_profession == "7") {
	$ps_profession = "其他";
}
$ps_education = $res ['ps_education'];
if ($ps_education == "5") {
	$ps_education = "初中及以下";
} else if ($ps_education == "0") {
	$ps_education = "未填写";
} else if ($ps_education == "1") {
	$ps_education = "高中及中专";
} else if ($ps_education == "2") {
	$ps_education = "大专";
} else if ($ps_education == "3") {
	$ps_education = "本科";
} else if ($ps_education == "4") {
	$ps_education = "硕士及以上";
}
$ps_marry_condition = $res ['ps_marry_condition'];
if ($ps_marry_condition == "0") {
	$ps_marry_condition = "未填写";
} else if ($ps_marry_condition == "1") {
	$ps_marry_condition = "未婚";
} else if ($ps_marry_condition == "2") {
	$ps_marry_condition = "离异";
} else if ($ps_marry_condition == "3") {
	$ps_marry_condition = "丧偶";
}
$ps_birthplace = $res ['ps_birthplace'];
$ps_monthly_income = $res ['ps_monthly_income'];
if ($ps_monthly_income == "0") {
	$ps_monthly_income = "未填写";
} else if ($ps_monthly_income == "3") {
	$ps_monthly_income = "小于2000";
} else if ($ps_monthly_income == "4") {
	$ps_monthly_income = "2000-5000元";
} else if ($ps_monthly_income == "5") {
	$ps_monthly_income = "5000-10000元";
} else if ($ps_monthly_income == "6") {
	$ps_monthly_income = "10000-20000元";
} else if ($ps_monthly_income == "7") {
	$ps_monthly_income = "20000以上";
}

$ps_Icon = $res ['ps_Icon'];
$ps_is_house = $res ['ps_is_house'];
if ($ps_is_house == "0") {
	$ps_is_house = "未填写";
} else if ($ps_is_house == "1") {
	$ps_is_house = "已购房";
} else if ($ps_is_house == "2") {
	$ps_is_house = "与父母同住";
} else if ($ps_is_house == "3") {
	$ps_is_house = "租房";
} else if ($ps_is_house == "4") {
	$ps_is_house = "其他";
}
$ps_birthday_year = $res ['ps_birthday_year'];
$now_data = getdate ();
$ps_birthday_year = ($now_data ["year"] - ( int ) $ps_birthday_year);
$ps_apartment = $res ['ps_apartment'];
if ($ps_apartment == "省份地 级市 市、县级市" || $ps_apartment == "0") {
	$ps_apartment = "居住地未填写";
}

$sql = "select * from `detail_data_tb` where `user_id`='$user_id'";
// 创建一个SqlHelper对象
$row = $sqlHelper->execute_dql ( $sql );
$res = mysql_fetch_array ( $row );
// 关闭连接
$dd_ischildren = $res ['dd_ischildren'];
if ($dd_ischildren == "0") {
	$dd_ischildren = "未填写";
} else if ($dd_ischildren == "1") {
	$dd_ischildren = "想";
} else if ($dd_ischildren == "2") {
	$dd_ischildren = "不想";
} else if ($dd_ischildren == "3") {
	$dd_ischildren = "还没想好";
}
$dd_islong_distance_love = $res ['dd_islong_distance_love'];
if ($dd_islong_distance_love == "0") {
	$dd_islong_distance_love = "未填写";
} else if ($dd_islong_distance_love == "1") {
	$dd_islong_distance_love = "能";
} else if ($dd_islong_distance_love == "2") {
	$dd_islong_distance_love = "看情况";
} else if ($dd_islong_distance_love == "3") {
	$dd_islong_distance_love = "不能";
}
$dd_like_type = $res ['dd_like_type'];
if ($dd_like_type == "6") {
	$dd_like_type = "成熟魅力";
} else if ($dd_like_type == "5") {
	$dd_like_type = "落落大方";
} else if ($dd_like_type == "7") {
	$dd_like_type = "眉清目秀";
} else if ($dd_like_type == "8") {
	$dd_like_type = "性感妩媚";
} else if ($dd_like_type == "2") {
	$dd_like_type = "善解人意";
} else if ($dd_like_type == "9") {
	$dd_like_type = "雍容华贵";
} else if ($dd_like_type == "1") {
	$dd_like_type = "活泼开朗";
} else if ($dd_like_type == "3") {
	$dd_like_type = "娇小可爱";
} else if ($dd_like_type == "4") {
	$dd_like_type = "温柔体贴";
} else if ($dd_like_type == "0") {
	$dd_like_type = "未填写";
}
$dd_is_premarital_sex = $res ['dd_is_premarital_sex'];
if ($dd_is_premarital_sex == "0") {
	$dd_is_premarital_sex = "未填写";
} else if ($dd_is_premarital_sex == "1") {
	$dd_is_premarital_sex = "能";
} else if ($dd_is_premarital_sex == "2") {
	$dd_is_premarital_sex = "看情况";
} else if ($dd_is_premarital_sex == "3") {
	$dd_is_premarital_sex = "不能";
}
$dd_live_with_parents = $res ['dd_live_with_parents'];
if ($dd_live_with_parents == "0") {
	$dd_live_with_parents = "未填写";
} else if ($dd_live_with_parents == "1") {
	$dd_live_with_parents = "愿意";
} else if ($dd_live_with_parents == "2") {
	$dd_live_with_parents = "看情况";
} else if ($dd_live_with_parents == "3") {
	$dd_live_with_parents = "不愿意";
}

$dd_ischildren = $res ['dd_ischildren'];
if ($dd_ischildren == "0") {
	$dd_ischildren = "未填写";
} else if ($dd_ischildren == "1") {
	$dd_ischildren = "想";
} else if ($dd_ischildren == "2") {
	$dd_ischildren = "不想";
} else if ($dd_ischildren == "3") {
	$dd_ischildren = "还没想好";
}
$dd_charm_point = $res ['dd_charm_point'];
if ($dd_charm_point == "0") {
	$dd_charm_point = "未填写";
} else if ($dd_charm_point == "1") {
	$dd_charm_point = "笑容";
} else if ($dd_charm_point == "2") {
	$dd_charm_point = "眉毛";
} else if ($dd_charm_point == "3") {
	$dd_charm_point = "眼睛";
} else if ($dd_charm_point == "4") {
	$dd_charm_point = "头发";
} else if ($dd_charm_point == "5") {
	$dd_charm_point = "鼻梁";
} else if ($dd_charm_point == "6") {
	$dd_charm_point = "嘴唇";
} else if ($dd_charm_point == "7") {
	$dd_charm_point = "牙齿";
} else if ($dd_charm_point == "8") {
	$dd_charm_point = "颈部";
} else if ($dd_charm_point == "9") {
	$dd_charm_point = "耳朵";
} else if ($dd_charm_point == "10") {
	$dd_charm_point = "手";
} else if ($dd_charm_point == "11") {
	$dd_charm_point = "胳膊";
} else if ($dd_charm_point == "12") {
	$dd_charm_point = "胸部";
} else if ($dd_charm_point == "13") {
	$dd_charm_point = "腰部";
} else if ($dd_charm_point == "14") {
	$dd_charm_point = "脚";
} else if ($dd_charm_point == "15") {
	$dd_charm_point = "腿";
} else if ($dd_charm_point == "16") {
	$dd_charm_point = "臀部";
}
$dd_hobby = $res ['dd_hobby'];
$dd_personality1 = $res ['dd_personality'];
$dd_soliloquy = $res ['dd_soliloquy'];
if ($dd_soliloquy == "0") {
	$dd_soliloquy = "未填写";
}
$dd_hobby_str = str_split ( $dd_hobby, 1 );
$dd_personality = str_split ( $dd_personality1, 1 );

$sql = "select * from `personals_condition_tb` where `user_id`='$user_id'";
// 创建一个SqlHelper对象
$row = $sqlHelper->execute_dql ( $sql );
$res = mysql_fetch_array ( $row );
// 关闭连接
$pc_address = $res ['pc_address'];
$pc_min_age = $res ['pc_min_age'];
$pc_max_age = $res ['pc_max_age'];
$pc_education = $res ['pc_education'];
if ($pc_education == "0") {
	$pc_education = "不限制";
} else if ($pc_education == "5") {
	$pc_education = "初中及以下";
} else if ($pc_education == "1") {
	$pc_education = "高中及中专";
} else if ($pc_education == "2") {
	$pc_education = "大专";
} else if ($pc_education == "3") {
	$pc_education = "本科";
} else if ($pc_education == "4") {
	$pc_education = "硕士及以上";
}
$pc_min_height = $res ['pc_min_height'];
$pc_max_height = $res ['pc_max_height'];
$pc_income = $res ['pc_income'];
if ($pc_income == "0") {
	$pc_income = "不限制";
} else if ($pc_income == "3") {
	$pc_income = "小于2000";
} else if ($pc_income == "4") {
	$pc_income = "2000-5000";
} else if ($pc_income == "5") {
	$pc_income = "5000-10000";
} else if ($pc_income == "6") {
	$pc_income = "10000-20000";
} else if ($pc_income == "7") {
	$pc_income = "20000以上";
}
mysql_free_result ( $row );
$sqlHelper->close_connect ();
?>
<title><?php echo $user_name;?>的空间</title>
<link href="./Resource/Style/user_space.yy.css" rel="stylesheet"
	type="text/css" />
</head>
<body>
	<div class="yy_header">
		<div class="yy_nav">
			<span class="logo" title="找对象，上友缘网！"
				style="background-image: url('../PersonalPhoto/Images/logo.png');"><a
				href="#"></a></span>
			<ul>
				<li><a class="a_01 a_out" href="../Space/SpaceIndex.php"><span
						style="background-image: url('../PersonalPhoto/Images/Space.png');"></span>空间</a></li>
				<li><a class="a_01" href="../SearchMargin/SearchMarginIndex.php"><span
						style="background-image: url('../PersonalPhoto/Images/Search.png');"></span>搜缘</a></li>
				<li><a class="a_01" href="../Serve/ServeIndex.php"><span
						style="background-image: url('../PersonalPhoto/Images/Serve.png');">
					</span>服务</a></li>
				<li><a class="a_01" href="../Mailbox/MailboxIndex.php"><span
						style="background-image: url('../PersonalPhoto/Images/Mailbox.png');"></span>信箱</a></li>
			</ul>
			<div id="mineInfo" class="set_up ">
				<em class="tipParent"></em> <span style="font-size: 16px;"
					title="<?php echo $_SESSION ["userinfo"] ["username"];?>">你好，<?php echo $_SESSION ["userinfo"] ["username"];?>
					<a style="font-size: 12px;" href="../index.php?exit=1">安全退出</a></span>
			</div>
		</div>
	</div>
	<div class="y_user y_user_02">
		<div class="con">
			<div class="con_title"></div>
			<dl class="personal_cen">
				<dt>
					<img
						src=<?php
						if ($ps_Icon == "0") {
							$user_img_path = "../PersonalPhoto/Images/nohead_new.jpg";
							echo $user_img_path;
						} else {
							$path = "../PersonalPhoto/" . $user_id . "/";
							$user_image_name = $path . $ps_Icon;
							echo "'" . $user_image_name . "'";
						}
						?>
						width="174" height="214">
				</dt>
				<dd>
					<div class="main">
						<strong><?php echo $user_name;?></strong>
					</div>
					<p class="local"><?php
					echo $ps_apartment . " " . $ps_birthday_year . "岁 " . $ps_height . "cm " . $ps_monthly_income . " " . $ps_is_house;
					?></p>
					<ol class="hoby">
					<?php
					if ($dd_hobby_str [0] == "1") {
						echo "
						<li>上网</li>";
					}
					if ($dd_hobby_str [1] == "1") {
						echo "
						<li>研究汽车</li>";
					}
					if ($dd_hobby_str [2] == "1") {
						echo "
						<li>养小动物</li>";
					}
					if ($dd_hobby_str [3] == "1") {
						echo "
						<li>摄影</li>";
					}
					if ($dd_hobby_str [4] == "1") {
						echo "
						<li>看电影</li>";
					}
					if ($dd_hobby_str [5] == "1") {
						echo "
						<li>听音乐</li>";
					}
					if ($dd_hobby_str [6] == "1") {
						echo "
						<li>写作</li>";
					}
					if ($dd_hobby_str [7] == "1") {
						echo "
						<li>购物</li>";
					}
					if ($dd_hobby_str [9] == "1") {
						echo "
						<li>做园艺</li>";
					}
					if ($dd_hobby_str [10] == "1") {
						echo "
						<li>跳舞</li>";
					}
					if ($dd_hobby_str [11] == "1") {
						echo "
						<li>看展览</li>";
					}
					if ($dd_hobby_str [12] == "1") {
						echo "
						<li>烹饪</li>";
					}
					if ($dd_hobby_str [13] == "1") {
						echo "
						<li>读书</li>";
					}
					if ($dd_hobby_str [14] == "1") {
						echo "
						<li>绘画</li>";
					}
					if ($dd_hobby_str [15] == "1") {
						echo "
						<li>研究计算机</li>";
					}
					if ($dd_hobby_str [16] == "1") {
						echo "
						<li>做运动</li>";
					}
					if ($dd_hobby_str [17] == "1") {
						echo "
						<li>旅游</li>";
					}
					if ($dd_hobby_str [18] == "1") {
						echo "
						<li>玩电子游戏</li>";
					}
					if ($dd_hobby_str [19] == "1") {
						echo "
						<li>其它</li>";
					}
					if ($dd_personality [0] == "1") {
						echo "
						<li>宅</li>";
					}
					if ($dd_personality [1] == "1") {
						echo "
						<li>感性</li>";
					}
					if ($dd_personality [2] == "1") {
						echo "
						<li>体贴</li>";
					}
					if ($dd_personality [3] == "1") {
						echo "
						<li>憨厚</li>";
					}
					if ($dd_personality [4] == "1") {
						echo "
						<li>稳重</li>";
					}
					if ($dd_personality [5] == "1") {
						echo "
						<li>好强</li>";
					}
					if ($dd_personality [6] == "1") {
						echo "
						<li>冷静</li>";
					}
					if ($dd_personality [7] == "1") {
						echo "
						<li>温柔</li>";
					}
					if ($dd_personality [8] == "1") {
						echo "
						<li>自我</li>";
					}
					if ($dd_personality [9] == "1") {
						echo "
						<li>闷骚</li>";
					}
					if ($dd_personality [10] == "1") {
						echo "
						<li>正直</li>";
					}
					if ($dd_personality [11] == "1") {
						echo "
						<li>幽默</li>";
					}
					if ($dd_personality [12] == "1") {
						echo "
						<li>讲义气</li>";
					}
					if ($dd_personality [13] == "1") {
						echo "
						<li>孝顺</li>";
					}
					if ($dd_personality [14] == "1") {
						echo "
						<li>勇敢</li>";
					}
					if ($dd_personality [15] == "1") {
						echo "
						<li>有责任心</li>";
					}
					if ($dd_personality [16] == "1") {
						echo "
						<li>好动</li>";
					}
					if ($dd_personality [17] == "1") {
						echo "
						<li>随和</li>";
					}
					?>
					</ol>
					<div class="select_hello">
					<?php if($user_id != $myid){?>
						<a
							href="./PersonalSpace.php?dazhaohu=<?php echo $user_id;?>&user_name=<?php echo $user_name;?>"
							class="sayHiBtn hello"><span>打招呼</span> </a><a
							href="./PersonalSpace.php?attention=<?php echo $user_id;?>&user_name=<?php echo $user_name;?>"
							class="attion follow setAttention"><span>关注ta</span></a>
						<?php }?>
					</div>
				</dd>
			</dl>
		</div>
	</div>
	<div id="photo" class="photo">
		<!--索要照片-->
		<!--索要照片end-->
		<!--照片展示-->
		<div class="ph_show">
			<ul class="block_photo">
				<?php
				$sqlHelper = new SqlHelper ();
				$sql = "select ax_value from `auxiliary_tb` where `user_id`='$user_id' and `ax_property` = 'photo'";
				$res = $sqlHelper->execute_dql ( $sql );
				$path = "../PersonalPhoto/" . $user_id . "/";
				$num = 0;
				while ( $row = mysql_fetch_assoc ( $res ) ) {
					if ($num ++ < 6) {
						echo "<li class='smallPhoto'>";
						echo "<a class='fancybox' href='" . $path . $row ['ax_value'] . "' data-fancybox-group='gallery' title='Show Love'>";
						echo "<img width='110' height='110' alt='照片' src='" . $path . $row ['ax_value'] . "' />";
						echo "</a></li>";
					}
				}
				$sqlHelper->close_connect ();
				?>
				<li class="needPhoto"><a
					href="./PersonalSpace.php?error=<?php echo $user_id;?>"
					class="need_photo"><img width="110" height="110" alt='照片'
						src="../PersonalPhoto/Images/suoyaoPhoto.png" /></a></li>

			</ul>
		</div>
		<!--照片展示end-->
	</div>
	<!--个人资料start-->
	<div class="pre_data">
		<strong class="tit_main"><?php echo $user_name;?>的个人资料</strong>
		<ul class="requre">
			<li>
				<h2><?php echo $user_name;?>的内心独白</h2>
				<p><?php echo $dd_soliloquy;?></p>
			</li>
			<li>
				<h2><?php echo $user_name;?>的详细资料</h2>
				<div class="message">
					<ol>
						<li>性 别：<span class="black"><?php echo $user_sex;?></span></li>
						<li>体 重：<span class="black"><?php echo $ps_weight;?>斤</span></li>
						<li>学 历：<span class="black"><?php echo $ps_education;?></span></li>
						<li>月 薪：<span class="black"><?php echo $ps_monthly_income;?></span></li>
						<li>是否想要小孩：<span class="black"><?php echo $dd_ischildren;?></span></li>
						<li>喜欢的异性类型：<span class="black"><?php echo $dd_like_type;?></span></li>
						<li>是否愿意与父母同住：<span class="black"><?php echo $dd_live_with_parents;?></span></li>
					</ol>
					<ol>
						<li>婚姻：<span class="black"><?php echo $ps_marry_condition;?></span></li>
						<li>身高：<span class="black"><?php echo $ps_height;?>cm</span></li>
						<li>职业：<span class="black"><?php echo $ps_profession;?></span></li>
						<li>住房：<span class="black"><?php echo $ps_is_house;?></span></li>
						<li>能否接受异地恋：<span class="black"><?php echo $dd_islong_distance_love;?></span></li>
						<li>能否接受婚前性行为：<span class="black"><?php echo $dd_is_premarital_sex;?></span></li>
						<li>最有魅力的部位：<span class="black"><?php echo $dd_charm_point;?></span></li>
					</ol>
				</div>
			</li>
			<div class="clear"></div>
			<li>
				<h2><?php echo $user_name;?>的征友条件</h2>
				<div class="message">
					<ol>
						<li>所在地区：<span class="black"><?php echo $pc_address;?></span></li>
						<li>身高：<span class="black"> <?php echo $pc_min_height;?>厘米 ～<?php echo $pc_max_height?>厘米 </span></li>
						<li>收入：<span class="black"><?php echo $pc_income;?></span></li>
					</ol>
					<ol>
						<li>年龄：<span class="black"> <?php echo $pc_min_age;?>岁 ～ <?php echo $pc_max_age?>岁</span></li>
						<li>学历：<span class="black"><?php echo $pc_education;?></span></li>
					</ol>
					<?php if($user_id != $myid){?>
					<font class="prompt">以上并不是硬性要求，快来和我联系吧。</font>
					<?php }?>
				</div>
			</li>
			<div class="clear"></div>
		</ul>
		<div class="hi">
			<div class="hi_box">
			<?php if($user_id != $myid){?>
				<a title="打招呼" class="sayHiBtn hello"
					href="./PersonalSpace.php?dazhaohu=<?php echo $user_id;?>&user_name=<?php echo $user_name;?>"><span>打招呼</span></a>><a
					class="attion setAttention attion_he"
					href="./PersonalSpace.php?attention=<?php echo $user_id;?>&user_name=<?php echo $user_name;?>"
					title="关注">关注ta</a>
					<?php }?>
			</div>
		</div>
	</div>
</body>
</html>